// *********************************************************
//      Copyright (c) Kosta Gaitanis
//      All rights reserved
//
//      k.gaitanis@gmail.com
//
// *********************************************************

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "World.h"
#include "GLWidget.h"
#include "ItemsListWidget.h"
#include "MaterialWidget.h"
#include "LightsListWidget.h"
#include "TextureListWidget.h"
#include "CameraWidget.h"
#include "RenderWidget.h"

#include <QtWidgets/QMainWindow>

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

    Camera* getCamera() const;
    World* getWorld() const;

    void addItem(Item* item);
    void addLight(Light* light);
    void addTexture(const Texture* texture);
    void bindTexture(const Texture* texture, Item* item);
    void setCameraTarget(const Item* item);

private slots:
    void initializeGL();
    void paintGL();
    void onMaterialChanged();
    void onTextureChanged(const Texture* texture);
    void onZoomBy(int zoomFactor);
    void onMoveCameraBy(int x, int y);
    void onRotateCameraBy(double angle);
    void onItemSelected(const Item* item);
    void onTimer(int t);
    void onPlayPauseClicked();

    void updateGLWidget();

protected:
    void closeEvent(QCloseEvent *);

private:
    void createMainContent();
    void makeSignalConnections();

    GLWidget *m_glWidget;
    World* m_world;
    ItemsListWidget *m_itemsWidget;
    MaterialWidget *m_materialWidget;
    LightsListWidget *m_lightsWidget;
    TextureListWidget *m_textureWidget;
    RenderWidget *m_renderWidget;

    QTimeLine *m_timeLine;
    QPushButton *m_playPauseButton;
    QDoubleSpinBox *m_speedSpinBox;
    CameraWidget *m_cameraWidget;
    QDoubleSpinBox *m_gammaCorrection;
};

#endif // MAINWINDOW_H
